//
//  ConsumeQueue.h
//  BaseProject
//
//  Created by HanFeng on 14-4-3.
//  Copyright (c) 2014年 mafengwo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Consumer.h"

typedef enum {
    ComsumerPriority_Undefined = 0,
    ComsumerPriority_Low = 250,
    ConsumerPriority_High = 1000,
    ConsumerPriority_Default = 500,
} ConsumerPriority;

@interface Consumer (Priority)

@property (nonatomic, assign) NSInteger priority;

@end

@protocol ConsumeQueue <NSObject>

@property (nonatomic, readonly) NSArray *priorityQueue;

/**
 *  同等优先级，先添加的优先级高于后添加的
 *  默认优先级 ConsumerPriority_Default
 */
- (void)addConsumer:(Consumer *)consumer;
- (void)addConsumer:(Consumer *)consumer priority:(NSInteger)priority;

- (void)deleteConsumer:(Consumer *)consumer;

/**
 *  消费
 */
- (BOOL)consume:(ConsumedObject *)object;
- (BOOL)consume:(ConsumedObject *)object outConsumer:(Consumer **)consumer;

- (void)clearAllConsumers;

@end

@interface ConsumeQueue : NSObject <ConsumeQueue>

@end
